// 文章相关的mock数据
import { mock, Random } from 'mockjs'

// 生成文章列表数据
export const getArchivesList = mock({
  'code': 1,
  'msg': '操作成功',
  'data': {
    'pageList': {
      'total': '@integer(100, 200)',
      'per_page': 10,
      'current_page': 1,
      'last_page': '@integer(10, 20)',
      'data|10': [{
        'id': '@id',
        'eid': '@string("lower", 10)',
        'title': '@ctitle(10, 30)',
        'image': '@image("200x150", "#4A7BF7", "CMS")',
        'images': '@image("200x150", "#4A7BF7", "CMS"),@image("200x150", "#4A7BF7", "CMS"),@image("200x150", "#4A7BF7", "CMS")',
        'images_list|3': ['@image("200x150", "#4A7BF7", "CMS")'],
        'channel_id': '@integer(1, 10)',
        'channel': {
          'id': '@integer(1, 10)',
          'name': '@cword(2, 4)',
          'image': '@image("100x100", "#4A7BF7", "CMS")',
          'diyname': '@word(5, 10)',
          'items': '@integer(50, 200)'
        },
        'user_id': '@integer(1, 100)',
        'user': {
          'id': '@integer(1, 100)',
          'nickname': '@cname',
          'avatar': '@image("100x100", "#4A7BF7", "Avatar")'
        },
        'likes': '@integer(0, 1000)',
        'dislikes': '@integer(0, 100)',
        'comments': '@integer(0, 500)',
        'views': '@integer(100, 10000)',
        'create_date': '@date("yyyy-MM-dd")',
        'createtime': '@integer(1600000000, 1630000000)',
        'publishtime': '@integer(1600000000, 1630000000)',
        'description': '@cparagraph(1, 3)',
        'price': '@float(0, 100, 2, 2)',
        'tags': '@cword(2),@cword(2),@cword(2)',
        'taglist|3': [{
          'id': '@id',
          'name': '@cword(2, 4)'
        }]
      }]
    },
    'filterList': [],
    'orderList': [],
    'channel': {
      'id': '@integer(1, 10)',
      'name': '@cword(2, 4)',
      'image': '@image("100x100", "#4A7BF7", "CMS")',
      'diyname': '@word(5, 10)',
      'items': '@integer(50, 200)',
      'parent_id': 0
    }
  }
})

// 生成文章详情数据
export const getArchivesDetail = mock({
  'code': 1,
  'msg': '操作成功',
  'data': {
    'archivesInfo': {
      'id': '@id',
      'eid': '@string("lower", 10)',
      'title': '@ctitle(10, 30)',
      'image': '@image("200x150", "#4A7BF7", "CMS")',
      'images': '@image("200x150"),@image("200x150"),@image("200x150")',
      'channel_id': '@integer(1, 10)',
      'channel': {
        'id': '@integer(1, 10)',
        'name': '@cword(2, 4)',
        'image': '@image("100x100", "#4A7BF7", "CMS")',
        'diyname': '@word(5, 10)',
        'items': '@integer(50, 200)',
        'vip': '@integer(0, 3)'
      },
      'user_id': '@integer(1, 100)',
      'user': {
        'id': '@integer(1, 100)',
        'nickname': '@cname',
        'avatar': '@image("100x100", "#4A7BF7", "Avatar")',
        'bio': '@cparagraph(1)'
      },
      'likes': '@integer(0, 1000)',
      'dislikes': '@integer(0, 100)',
      'comments': '@integer(0, 500)',
      'views': '@integer(100, 10000)',
      'create_date': '@date("yyyy-MM-dd")',
      'createtime': '@integer(1600000000, 1630000000)',
      'publishtime': '@integer(1600000000, 1630000000)',
      'description': '@cparagraph(1, 3)',
      'content': '<p>@cparagraph(10, 20)</p><p>@cparagraph(10, 20)</p><p>@cparagraph(10, 20)</p>',
      'price': '@float(0, 100, 2, 2)',
      'ispaid': '@boolean',
      'iscomment': true,
      'tags': '@cword(2),@cword(2),@cword(2)',
      'taglist|3': [{
        'id': '@id',
        'name': '@cword(2, 4)'
      }],
      'downloadurl|0-3': [{
        'name': 'local',
        'url': '@url'
      }, {
        'name': 'baidu',
        'url': '@url',
        'password': '@string("lower", 4)'
      }]
    },
    'commentList|5': [{
      'id': '@id',
      'user_id': '@integer(1, 100)',
      'user': {
        'id': '@integer(1, 100)',
        'nickname': '@cname',
        'avatar': '@image("100x100", "#4A7BF7", "Avatar")'
      },
      'content': '@cparagraph(1, 3)',
      'create_date': '@date("yyyy-MM-dd")',
      'createtime': '@integer(1600000000, 1630000000)'
    }],
    '__token__': '@guid'
  }
})

// 文章点赞/踩
export const voteArchives = mock({
  'code': 1,
  'msg': '点赞成功！',
  'data': {
    'likes': '@integer(0, 1000)',
    'dislikes': '@integer(0, 100)',
    'likeratio': '@float(0, 100, 2, 2)'
  }
})

// 提交文章订单（付费阅读）
export const submitOrder = mock({
  'code': 1,
  'msg': '请求成功',
  'data': {
    'orderid': '@id',
    'paytype': 'wechat',
    'payamount': '@float(0, 100, 2, 2)',
    'paydata': {
      'appid': 'wx123456789',
      'noncestr': '@guid',
      'package': 'prepay_id=wx123456789',
      'timestamp': '@integer(1600000000, 1630000000)',
      'sign': '@guid'
    }
  }
})

// 获取栏目
export const getChannel = mock({
  'code': 1,
  'msg': '操作成功',
  'data': {
    'channel|10': [{
      'id': '@id',
      'parent_id': '@integer(0, 5)',
      'name': '@cword(2, 4)',
      'type': 'channel',
      'model_id': '@integer(1, 5)',
      'disabled': '@boolean'
    }],
    'channel_id': '@integer(1, 10)'
  }
})

// 获取栏目字段
export const getChannelFields = mock({
  'code': 1,
  'msg': '操作成功',
  'data': {
    'contributefields': ['title', 'image', 'images', 'content', 'tags', 'price'],
    'fields|10': [{
      'name': '@word(4, 8)',
      'type': '@pick(["string", "text", "editor", "image", "images", "number", "radio", "checkbox", "select", "array", "date", "time", "datetime"])',
      'title': '@cword(2, 4)',
      'value': '',
      'defaultvalue': '',
      'rule': '',
      'tips': '@csentence(5, 10)',
      'ok': '',
      'msg': '',
      'isrequire': '@boolean'
    }],
    'values': {},
    'archives': null,
    'secondList|5': [{
      'id': '@id',
      'parent_id': '@integer(0, 5)',
      'name': '@cword(2, 4)',
      'type': 'channel',
      'model_id': '@integer(1, 5)',
      'disabled': '@boolean'
    }]
  }
})

// 发布文章
export const postArchives = mock({
  'code': 1,
  'msg': '发布成功！',
  'data': {}
})

// 获取我的文章
export const getMyArchives = mock({
  'code': 1,
  'msg': '操作成功',
  'data': {
    'archivesList': {
      'total': '@integer(10, 50)',
      'per_page': 10,
      'current_page': 1,
      'last_page': '@integer(1, 5)',
      'data|10': [{
        'id': '@id',
        'eid': '@string("lower", 10)',
        'title': '@ctitle(10, 30)',
        'image': '@image("200x150", "#4A7BF7", "CMS")',
        'images': '@image("200x150"),@image("200x150"),@image("200x150")',
        'images_list|3': ['@image("200x150", "#4A7BF7", "CMS")'],
        'channel_id': '@integer(1, 10)',
        'channel': {
          'id': '@integer(1, 10)',
          'name': '@cword(2, 4)',
          'image': '@image("100x100", "#4A7BF7", "CMS")',
          'diyname': '@word(5, 10)',
          'items': '@integer(50, 200)'
        },
        'user_id': '@integer(1, 100)',
        'likes': '@integer(0, 1000)',
        'dislikes': '@integer(0, 100)',
        'comments': '@integer(0, 500)',
        'views': '@integer(100, 10000)',
        'create_date': '@date("yyyy-MM-dd")',
        'createtime': '@integer(1600000000, 1630000000)',
        'status': '@pick(["normal", "hidden"])'
      }]
    },
    'channelList|5': [{
      'id': '@integer(1, 10)',
      'parent_id': '@integer(0, 5)',
      'name': '@cword(2, 4)',
      'image': '@image("100x100", "#4A7BF7", "CMS")',
      'diyname': '@word(5, 10)',
      'items': '@integer(50, 200)'
    }]
  }
})

// 删除文章
export const deleteArchives = mock({
  'code': 1,
  'msg': '删除文档成功',
  'data': {}
})